package com.lzugis.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.lzugis.entity.SysUser;
import com.lzugis.service.ILoginService;
import com.lzugis.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

/**
 * @ClassName LoginServiceImpl
 * @Author lzugis
 * @Date 2020/9/15 16:28
 **/
@Service
public class LoginServiceImpl implements ILoginService {

    @Autowired
    private ISysUserService sysUserService;

    @Override
    public boolean login(SysUser sysUser) {
        String md5Pwd = DigestUtils.md5DigestAsHex(sysUser.getLoginPwd().getBytes());
        Wrapper wrapper = new EntityWrapper();
        wrapper.eq("login_name", sysUser.getLoginName());
        wrapper.eq("login_pwd", md5Pwd);
        SysUser selectUser = sysUserService.selectOne(wrapper);
        return selectUser == null ? false : true;
    }
}
